﻿using UnityEngine;

namespace ProjectMyFarmAndShe
{
    public class EggplantPlantItem : PlantItem
    {
        public override string Key => "茄子";

        public override SeedStates State => CurrentPlantState.CurrentState;
        

        private void Start()
        {
            UpdatePlant();
        }

        public override void ChangeDay()
        {
            mPlantCount += 1;
            ChangeSpeedState(mPlantCount);
        }

        /// <summary>
        /// 更改种植物状态
        /// 当当 前种植天数等于下一个植物所种植天数则切换到下一个状态
        /// </summary>
        /// <param name="plantCount">当前状态种植天数</param>
        void ChangeSpeedState(int plantCount)
        {
            if (CurrentPlantState.NextStateDay == plantCount && PlantStates.Count != 0)
            {
                PlantIndex += 1;
                UpdatePlant();
                PlantDead();
            }
        }

        /// <summary>
        /// 更新当前种植物状态 包括图片 种植物数据 重置当前种植天数
        /// </summary>
        public override void UpdatePlant()
        {
            CurrentPlantState = PlantStates[PlantIndex];
            ShowPlant(CurrentPlantState);
        }

        void ShowPlant(PlantState state)
        {
            mPlantCount = 0;
            Sprite.sprite = state.Icon;
        }

        public override void ChangeHarvestIcon()
        {
            Sprite.sprite = CanHarvestIcon;
        }
    }
}